<?php
require_once('modules/Dashboard/Activity.php');
require_once('modules/Dashboard/Model_Research.php');
 class DashboardController extends SugarController{

     public function action_loadUserReport(){
         global $mod_strings, $current_user;
         $act = new Activity();
         if($act->hasUserAccessToActivity($current_user->id)){
             $params = array_merge($_POST, $_GET);
             $smarty = new Sugar_Smarty();
             $user = new User();
             $user->retrieve($params["userId"]);

             $res = new Research($params['from'], $params['to']);
             $res->setReportForUser($params["userId"]);
             $report = $res->createUserReport();

             $smarty->assign('user', $user->toArray());
             $smarty->assign('params', $params);
             $smarty->assign('modStr', $mod_strings);
             $smarty->assign('report', $report);
             $smarty->assign('reportUserSummary', $res->reportUserSummary);
             echo $smarty->fetch('modules/Dashboard/user_report.tpl');
         }else{
             echo 'Access denied';
         }
     }
 }